package com.game.modular.game.battle.process.battleStage.actionPhase.actionPhase1;

import com.game.modular.game.battle.panel.attribute.PlayerHeroAttributeServiceImpl;
import com.game.modular.game.battle.panel.attribute.domain.PlayerHeroAttribute;
import com.game.modular.game.battle.panel.skillEffect.PvpSkillEffectServiceImpl;
import com.game.modular.game.playerAssets.domain.PlayerHero;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 1
 * 行动前准备
 */
@Slf4j
@Service
public class PreparationBeforeActionService {
    @Resource
    private PvpSkillEffectServiceImpl skillEffectService;
    @Resource
    private PlayerHeroAttributeServiceImpl attributeService;

    public void apply(Long battleId, PlayerHero actWJ) {
        List<PlayerHeroAttribute> playerHeroAttributes = attributeService.listCache(battleId);

        for (PlayerHeroAttribute playerHeroAttribute : playerHeroAttributes) {
            playerHeroAttribute.refreshRoundInfo();
            playerHeroAttribute.clearAction();
            if (playerHeroAttribute.getId().equals(actWJ.getId())){
                playerHeroAttribute.setPhase(21);
            }
            attributeService.saveCache(playerHeroAttribute);
        }
    }
}
